
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
//导入模块
import right from "./modules/rights"
import userinfo from "./modules/user"
import video from "./modules/video"
import homework from "./modules/homework"

//导入计算属性
import getter from "./getter"
//导入加载效果

let TOKEN = 'SET_TOKEN'
import { setItem, getItem, removeItem } from '@/utlis/storage'
export default new Vuex.Store({
  state: {
    user: getItem(TOKEN) || null,
    uid: 1364,
    id: null,
    isLoading:false
  },
  mutations: {
    //操作用户身份权限  进入不同页面
    setUid (state, val) {
      state.uid = val
    },
    setUser (state, user) {
      state.user = user
      setItem(TOKEN, user)
    },
    //清除token
    rmToken (state) {
      /* 点击退出登录 
      1-清除state中的user
      2-清除本地缓存
      */
      state.user = null
      removeItem(TOKEN)
    },
    setRouter (state, id) {
      state.id = id
    },
    //改变状态
    // changeisLoading(state, data) {
    //   state.isLoading = data
    //   }
  },
  actions: {
  },
  modules: {
    right, userinfo, video, homework
  },
  getters:{
  ...getter
  }
})
